import type { App } from "vue";

import { createRouter, createWebHashHistory } from "vue-router";

import { basicRoutes } from "./routes";
import { LAYOUT } from "./constant";

/* 创建一个可以被 Vue 应用使用的 Router 实例 */
export const router = createRouter({
  //创建一个 hash 历史记录,无需配置服务器
  history: createWebHashHistory(),

  // 是否应该禁止尾部斜杠。默认为假
  strict: true,

  //应该添加到路由器的初始路由列表。
  routes: [
    {
      path: "/",
      name: "Test",
      component: LAYOUT,
      children: [
        {
          path: "tooltip",
          component: () => import("@/views/test/tooltip/index.vue"),
        },
        {
          path: "icon",
          component: () => import("@/views/test/icon/index.vue"),
        },
        {
          path: "button",
          component: () => import("@/views/test/button/index.vue"),
        },
        {
          path: "dialog",
          component: () => import("@/views/test/dialog/index.vue"),
        },
      ],
    },
  ],
});

// 配置路由器
export function setupRouter(app: App<Element>) {
  app.use(router);
}
